import React ,{ Component } from 'react';
import { connect } from  'react-redux';
import { withRouter } from 'react-router-dom';
import { actionCreators } from './store';
import { DetailWrapper ,Header,Content } from './style';


class Detail extends Component {

    render(){
      const { title,content } = this.props;
      return (
         <DetailWrapper>
           <Header>{title}</Header>
           <Content dangerouslySetInnerHTML = {{ __html:content}} />
         </DetailWrapper>
      )

    }

    componentDidMount(){
    // 获取上一页传过来参数
    //  console.log(this.props.match.params.id);
      this.props.getDatailDate(this.props.match.params.id)
    }

}
const mapState = (state) =>({
  title: state.getIn(["detail","title"]),
  content:state.getIn(["detail","content"]),

})

const mapDispatch =(dispatch) =>({
    getDatailDate(id){
     dispatch(actionCreators.getDatailDate(id))
    }
})


export default  connect(mapState,mapDispatch)(withRouter(Detail));
